package com.jhg.drgclinicalpathway.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jhg.drgclinicalpathway.domain.VDCP费用记录;
import com.jhg.drgclinicalpathway.domain.W路径项目信息;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VDCP费用记录Dao extends BaseMapper<VDCP费用记录> {
    @Select({
            "<script>",
           " select distinct a.项目编码,b.名称 ,",
            "case when b.类型 like '%药%' then '建议用药' else '项目名称' end 分类",
            ",b.属性,b.说明,b.类型",
            "from LJ_临床路径项目明细 a left join LJ_临床路径项目 b on a.项目ID=b.ID",
            "where  a.项目编码 in",
            "<foreach collection='list' open='(' close=')' item='id' index='i' separator=','>",
            "#{id}",
            "</foreach>",
            "and 状态=0",
            "</script>"
    })
    public List<W路径项目信息> w路径项目信息(@Param("list") List<String> list);

    @Select({
            "<script>",
            "select b.名称,case when b.类型 like '%药%' then '建议用药' else '项目名称' end as 分类",
            ",b.说明,c.项目编码 ,b.属性",
            "from JC_疾病对应项目 a join LJ_临床路径项目 b on a.项目编码=b.id left join LJ_临床路径项目明细 c  on b.ID=c.项目ID",
            " left join JC_疾病对应项目_应用 d on a.id=d.id",
            "where 疾病编码=#{code} and DATEPART(year,a.修改时间)>1900 and (d.应用>1) ",
            "</script>"
    })
    public List<W路径项目信息> selectByDis2Must(@Param("code") String code);

    @Select({
            "<script>",
            "select b.项目编码 from LJ_临床路径项目 a left join LJ_临床路径项目明细 b on a.ID=b.项目ID",
            "where a.说明 in",
            "<foreach collection='list' open='(' close=')' item='id' index='i' separator=','>",
            "#{id}",
            "</foreach>",
            "</script>"

    })
    public List<String> 通过说明获取项目编码(@Param("list") List<String> ls);
}
